#include<iostream>
class myClass{
	private:
	  static const int age = 18;
	  int *code;
	public:
	  myClass(){
		  using namespace std;
		  code = NULL;
		  cout<<"default constructor"<<endl;
	  }
	  myClass(int *cd){
		  using namespace std;
		  code = new int(*cd);
		  cout<<"a constructor"<<endl;
	  }
	  myClass(const myClass &mc){//复制构造函数
		  using namespace std;
		  code = new int(*mc.code);
		  cout<<"copy constructor"<<endl;
	  }
	  myClass(myClass &&mc){//移动构造函数
		  using namespace std;
		  code =  mc.code;
		  mc.code = NULL;
		  cout<<"move constructor"<<endl;
	  }
	  void printAgeAndChangeCode() const{
		  using namespace std;
		  //cout<<code<<endl;
		  (*code)++;
		  cout<<age<<" "<<*code<<endl;
	  }
	  ~myClass(){
		  using namespace std;
		  cout<<"delete func"<<" "<<*code<<endl;
		  delete code;
	  }
};

void rref(myClass &&mc){
	 mc.printAgeAndChangeCode();
}
int main(void){
 using namespace std;
 int code = 100;
 myClass mc(&code);
 mc.printAgeAndChangeCode();
 
 
 rref(move(mc));
 mc.printAgeAndChangeCode();
 
 
 rref(myClass(move(mc)));
 mc.printAgeAndChangeCode();//报错，移动构造函数调用后，mc.code == NULL
 return 0;
}
